package com.wilmer.testRecordDetails.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wilmer.common.annotation.Log;
import com.wilmer.common.core.controller.BaseController;
import com.wilmer.common.core.domain.AjaxResult;
import com.wilmer.common.enums.BusinessType;
import com.wilmer.testRecordDetails.domain.YwTestRecordsDetails;
import com.wilmer.testRecordDetails.service.IYwTestRecordsDetailsService;
import com.wilmer.common.utils.poi.ExcelUtil;
import com.wilmer.common.core.page.TableDataInfo;

/**
 * 随堂测试记录详细Controller
 * 
 * @author zl
 * @date 2024-04-11
 */
@RestController
@RequestMapping("/testRecordDetails/testRecordDetails")
public class YwTestRecordsDetailsController extends BaseController
{
    @Autowired
    private IYwTestRecordsDetailsService ywTestRecordsDetailsService;

    /**
     * 查询随堂测试记录详细列表
     */
    @PreAuthorize("@ss.hasPermi('testRecordDetails:testRecordDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(YwTestRecordsDetails ywTestRecordsDetails)
    {
        startPage();
        List<YwTestRecordsDetails> list = ywTestRecordsDetailsService.selectYwTestRecordsDetailsList(ywTestRecordsDetails);
        return getDataTable(list);
    }

    /**
     * 导出随堂测试记录详细列表
     */
    @PreAuthorize("@ss.hasPermi('testRecordDetails:testRecordDetails:export')")
    @Log(title = "随堂测试记录详细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YwTestRecordsDetails ywTestRecordsDetails)
    {
        List<YwTestRecordsDetails> list = ywTestRecordsDetailsService.selectYwTestRecordsDetailsList(ywTestRecordsDetails);
        ExcelUtil<YwTestRecordsDetails> util = new ExcelUtil<YwTestRecordsDetails>(YwTestRecordsDetails.class);
        util.exportExcel(response, list, "随堂测试记录详细数据");
    }

    /**
     * 获取随堂测试记录详细详细信息
     */
    @PreAuthorize("@ss.hasPermi('testRecordDetails:testRecordDetails:query')")
    @GetMapping(value = "/{recordDetailsId}")
    public AjaxResult getInfo(@PathVariable("recordDetailsId") Long recordDetailsId)
    {
        return success(ywTestRecordsDetailsService.selectYwTestRecordsDetailsByRecordDetailsId(recordDetailsId));
    }

    /**
     * 新增随堂测试记录详细
     */
    @PreAuthorize("@ss.hasPermi('testRecordDetails:testRecordDetails:add')")
    @Log(title = "随堂测试记录详细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YwTestRecordsDetails ywTestRecordsDetails)
    {
        return toAjax(ywTestRecordsDetailsService.insertYwTestRecordsDetails(ywTestRecordsDetails));
    }

    /**
     * 修改随堂测试记录详细
     */
    @PreAuthorize("@ss.hasPermi('testRecordDetails:testRecordDetails:edit')")
    @Log(title = "随堂测试记录详细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YwTestRecordsDetails ywTestRecordsDetails)
    {
        return toAjax(ywTestRecordsDetailsService.updateYwTestRecordsDetails(ywTestRecordsDetails));
    }

    /**
     * 删除随堂测试记录详细
     */
    @PreAuthorize("@ss.hasPermi('testRecordDetails:testRecordDetails:remove')")
    @Log(title = "随堂测试记录详细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordDetailsIds}")
    public AjaxResult remove(@PathVariable Long[] recordDetailsIds)
    {
        return toAjax(ywTestRecordsDetailsService.deleteYwTestRecordsDetailsByRecordDetailsIds(recordDetailsIds));
    }
}
